//
// Created by 11067 on 2023/3/11.
//
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include "../src/OptionParser.h"
#include "../src/exceptions/WordListException.h"
TEST(OptionParserTest,Test1) {
    Options options{};
    const char *args[]{"cli.exe", "-n", "1_in.txt"};
    OptionParser::parse(3, const_cast<char **>(args), options);
    Options expect{
            CountType::WordChainCount,
            '\0',
            '\0',
            '\0',
            false,
            "1_in.txt",
    };
    ASSERT_EQ(options, expect);
}

TEST(OptionParserTest,Test2) {
    Options options{};
    const char *args[]{"cli.exe", "-w", "1_in.txt"};
    OptionParser::parse(3, const_cast<char **>(args), options);
    Options expect{
            CountType::MaxWordLengthWordChain,
            '\0',
            '\0',
            '\0',
            false,
            "1_in.txt",
    };
    ASSERT_EQ(options, expect);
}

TEST(OptionParserTest,Test3) {
    Options options{};
    const char *args[]{"cli.exe", "-c", "1_in.txt"};
    OptionParser::parse(3, const_cast<char **>(args), options);
    Options expect{
            CountType::MaxAlphabetLengthWordChain,
            '\0',
            '\0',
            '\0',
            false,
            "1_in.txt",
    };
    ASSERT_EQ(options, expect);
}

TEST(OptionParserTest,Test4) {
    Options options{};
    const char *args[]{"cli.exe", "-w", "1_in.txt", "-r"};
    OptionParser::parse(4, const_cast<char **>(args), options);
    Options expect{
            CountType::MaxWordLengthWordChain,
            '\0',
            '\0',
            '\0',
            true,
            "1_in.txt",
    };
    ASSERT_EQ(options, expect);
}

TEST(OptionParserTest,Test5) {
    Options options{};
    const char *args[]{"cli.exe","-r" ,"-w", "1_in.txt",};
    OptionParser::parse(4, const_cast<char **>(args), options);
    Options expect{
            CountType::MaxWordLengthWordChain,
            '\0',
            '\0',
            '\0',
            true,
            "1_in.txt",
    };
    ASSERT_EQ(options, expect);
}
TEST(OptionParserTest,Test6) {
    Options options{};
    const char *args[]{"cli.exe", "-w", "1_in.txt", "-h", "a"};
    OptionParser::parse(5, const_cast<char **>(args), options);
    Options expect{
            CountType::MaxWordLengthWordChain,
            'a',
            '\0',
            '\0',
            false,
            "1_in.txt",
    };
    ASSERT_EQ(options, expect);
}

TEST(OptionParserTest,Test7) {
    Options options{};
    const char *args[]{"cli.exe", "-w", "1_in.txt", "-t", "a"};
    OptionParser::parse(5, const_cast<char **>(args), options);
    Options expect{
            CountType::MaxWordLengthWordChain,
            '\0',
            'a',
            '\0',
            false,
            "1_in.txt",
    };
    ASSERT_EQ(options, expect);
}

TEST(OptionParserTest,Test8) {
    Options options{};
    const char *args[]{"cli.exe", "-w", "1_in.txt", "-t", "a", "-h", "a"};
    OptionParser::parse(7, const_cast<char **>(args), options);
    Options expect{
            CountType::MaxWordLengthWordChain,
            'a',
            'a',
            '\0',
            false,
            "1_in.txt",
    };
    ASSERT_EQ(options, expect);
}
TEST(OptionParserTest,Test9) {
    Options options{};
    const char *args[]{"cli.exe", "-w", "1_in.txt", "-j", "a"};
    OptionParser::parse(5, const_cast<char **>(args), options);
    Options expect{
            CountType::MaxWordLengthWordChain,
            '\0',
            '\0',
            'a',
            false,
            "1_in.txt",
    };
    ASSERT_EQ(options, expect);
}
TEST(OptionParserTest,Test10) {
    Options options{};
    const char *args[]{"cli.exe", "-w", "1_in.txt", "-j", "a", "-r"};
    OptionParser::parse(6, const_cast<char **>(args), options);
    Options expect{
            CountType::MaxWordLengthWordChain,
            '\0',
            '\0',
            'a',
            true,
            "1_in.txt",
    };
    ASSERT_EQ(options, expect);
}

TEST(OptionParserTest, ErrTest1) {
    Options options{};
    const char *args[]{"cli.exe", "-w", "1"};
    EXPECT_THROW(OptionParser::parse(3, const_cast<char **>(args), options), CLIOptionException);
}